package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Business;
import cn.wolfcode.domain.SystemDictionary;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ISystemDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
// 门店首页
@Controller
public class IndexController {
    @Autowired
    private IBusinessService businessService;
    @Autowired
    private ISystemDictionaryService systemDictionaryService;

    @RequestMapping("/index")
    public String index(Model model) {
        // 查找主店
        Business business = businessService.queryMainStore();
        model.addAttribute("main", business);

        // 通过编号来查找业务这一目录下的子级  参数是: 业务目录 的编码
        List<SystemDictionary> buss = systemDictionaryService.queryBySn("business");
        model.addAttribute("buss", buss);

        // 查找所有门店
        model.addAttribute("businesses", businessService.listAll());
        return "/index";
    }
}
